package DAO;

import Bean.User;

/**
 * @author jianjun
 * @Describe
 * @creat 2021-12-13-11:09
 */
public class UserDAOImpl extends BaseDAO implements UserDAO {
    @Override
    public User queryUserByUsername(String username) {
        String sql = "select `id`,`username`,`password`,`email` from t_user where username = ?";
        return queryForOne(User.class,sql,username);
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        String sql = "select `id`,`username`,`password`,`email` from t_user where username = ? and password = ?";
        return queryForOne(User.class,sql,username,password);
    }

    @Override
    public int SaveUser(User user) {
        String sql = "insert into t_user(username,password,email) value(?,?,?)";
        return updata(sql,user.getUsername(),user.getPassword(),user.getEmail());
    }
}
